package org.s3.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.s3.project.entity.Dish;
import org.s3.project.mapper.DishMapper;
import org.s3.project.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author cfx
 * @version 1.0
 * @Description
 * @date 2025/2/9 10:15
 */
@Service
public class DishServiceImpl extends ServiceImpl<DishMapper, Dish> implements DishService {
    @Autowired
    private DishMapper dishMapper;
    //查询显示
    @Override
    public List<Dish> getDishSelect() {
        return dishMapper.getDishSelect();
    }
    // 查询商家所有菜品
    @Override
    public List<Dish> selectAllByBusinessId(Integer businessId) {
        return dishMapper.selectAllByBusinessId(businessId);
    }

    @Override
    public List<Dish> getDishSelectByInventory() {
        return dishMapper.getDishSelectByInventory();
    }

    //修改
    @Override
    public int updateDish(Dish dish) {
        return dishMapper.updateDish(dish);
    }
    //新增
    @Override
    public int insertDish(Dish dish) {
        return dishMapper.insertDish(dish);
    }


    @Override
    public Dish getDishId(int id) {
        return dishMapper.getDishId(id);
    }

    @Override
    public List<Dish> selectDishByMerchant(int id) {
        return dishMapper.selectDishByMerchant(id);
    }

    @Override
    public List<Dish> selectBusinessId(int id, int category_id) {
        return dishMapper.selectBusinessId(id,category_id);
    }

    @Override
    public List<Dish> getDishByCategoryId(int id) {
        return dishMapper.getDishByCategoryId(id);
    }

    @Override
    public List<Dish> getDishByDishName(String name) {
        return dishMapper.selectDishByName(name);
    }
    /**
     * 根据商家id查询菜品(与刘家辉的略有不同)
     * @param id 商家id
     * @return 菜品列表
     */
    @Override
    public List<Dish> selectDishByMerchants(@Param("id") Integer id,@Param("Dname")String Dname,@Param("create_time")String create_time, @Param("create_timeOne")String create_timeOne,@Param("status")Integer status) {
        return dishMapper.selectDishByMerchants(id,Dname,create_time,create_timeOne,status);
    }
    /**
     * 修改菜品状态
     * @param dish 菜品对象
     * @return 修改结果
     */
    @Override
    public int updateDishStatus(Dish dish) {
        return dishMapper.updateDishStatus(dish);
    }
    /**
     * 批量修改菜品状态
     * @param ids 菜品id数组
     * @param dish 菜品对象
     * @return 修改结果
     */
    @Override
    public int updateDishStatusIds(@Param("ids")int[] ids,Dish dish) {
        return dishMapper.updateDishStatusIds(ids,dish);
    }
    /**
     * 分页查询菜品信息
     * @param Dname 菜品名称
     * @param Mname 商家名称
     * @param create_time 创建时间
     * @param create_timeOne 创建时间
     * @return
     */
    @Override
    public List<Dish> selectDishByMerchantChecks(String Dname, String Mname, String create_time, String create_timeOne) {
        return dishMapper.selectDishByMerchantChecks(Dname,Mname,create_time,create_timeOne);
    }
}
